﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using System.Collections.Generic;
using ClassLibrary.DAO;

public partial class Yumcha_UcControl_ucOrder : System.Web.UI.UserControl
{
    TblCustomersDAO customerDAO = new TblCustomersDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           
        }
    }
    protected void bt_set_Click(object sender, EventArgs e)
    {
        bool flag = false;
        try
        {
            #region Insert Customer
            // insert Customer
            TblCustomers customer = new TblCustomers();
            customer.FName = txt_fistname.Text;
            customer.LName = txt_lastname.Text;
            customer.Company = "";
            customer.CusAddress = txt_address.Text;
            customer.EmailAdress = txt_email.Text;
            customer.CusState = "";
            customer.Postcode = "";
            customer.Suburb = "";
            customer.HomePhone = "";
            customer.WorkPhone = "";
            customer.MobilePhone = txtmobilephone.Text;
            customer.Password = "";

            String id = Request.QueryString["id"];

            DataTable dt = null;

            if (id == "" || id == null)
            {
                customer.CusID = 0;
                dt = customerDAO.Insert_Up(customer, 1);

                foreach (DataRow dr in dt.Rows)
                {
                    customer.CusID = Convert.ToInt32(dr["CusID"].ToString());

                }
            }
            else
            {
                customer.CusID = Global.ConvertToInt(id);
                customerDAO.Insert_Up(customer, 2);
            }
        }
        catch(Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE, true);
        }
        if (flag)
        {
            Response.Redirect("/ShoppingCart.aspx");
        }

        #endregion
    }

}
